/*
Date:20210526 0:11AM
key:偶数就现存好，在y*y,奇数就x*digui
*/
class Solution {
public:
    double myPow1(double x, int n) 
    {
        if(n<1){return 1;}
        if(n&1)
        {
            return x*myPow(x,n-1);
        }
        else
        {
            double y =myPow(x,n>>1);
            return y*y;
        }
    }
    double myPow2(double x, int n) 
    {
        if(n<1){return 1;}
        if(n&1)
        {
            return 1/(x*myPow(x,n-1));
        }
        else
        {
            double y =myPow(x,n>>1);
            return 1/(y*y);
        }
    }
    double myPow(double x, int n) 
    {
        if(n==0||x==1){return 1;}
        if(x==-1){if(n==2147483647){return -1;}else{{return 1;}}}
        if(n>0){return myPow1(x,n);}
        else
        {
            if(n==-2147483648){return 0;}
            return 1/myPow1(x,n*(-1));
        }
    }
};